package com.ruoyi.web.controller.combat.useralignment;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.combat.domain.useralignment.CombatBlogZh;
import com.ruoyi.combat.service.useralignment.ICombatBlogZhService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 知乎用户发布内容Controller
 * 
 * @author ruoyi
 * @date 2025-03-10
 */
@RestController
@RequestMapping("/combat/blogzh")
public class CombatBlogZhController extends BaseController
{
    @Autowired
    private ICombatBlogZhService combatBlogZhService;

    /**
     * 查询知乎用户发布内容列表
     */
    @PreAuthorize("@ss.hasPermi('combat:blogzh:list')")
    @GetMapping("/list")
    public TableDataInfo list(CombatBlogZh combatBlogZh)
    {
        startPage();
        List<CombatBlogZh> list = combatBlogZhService.selectCombatBlogZhList(combatBlogZh);
        return getDataTable(list);
    }

    /**
     * 导出知乎用户发布内容列表
     */
    @PreAuthorize("@ss.hasPermi('combat:blogzh:export')")
    @Log(title = "知乎用户发布内容", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CombatBlogZh combatBlogZh)
    {
        List<CombatBlogZh> list = combatBlogZhService.selectCombatBlogZhList(combatBlogZh);
        ExcelUtil<CombatBlogZh> util = new ExcelUtil<CombatBlogZh>(CombatBlogZh.class);
        util.exportExcel(response, list, "知乎用户发布内容数据");
    }

    /**
     * 获取知乎用户发布内容详细信息
     */
    @PreAuthorize("@ss.hasPermi('combat:blogzh:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(combatBlogZhService.selectCombatBlogZhById(id));
    }

    /**
     * 新增知乎用户发布内容
     */
    @PreAuthorize("@ss.hasPermi('combat:blogzh:add')")
    @Log(title = "知乎用户发布内容", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CombatBlogZh combatBlogZh)
    {
        return toAjax(combatBlogZhService.insertCombatBlogZh(combatBlogZh));
    }

    /**
     * 修改知乎用户发布内容
     */
    @PreAuthorize("@ss.hasPermi('combat:blogzh:edit')")
    @Log(title = "知乎用户发布内容", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CombatBlogZh combatBlogZh)
    {
        return toAjax(combatBlogZhService.updateCombatBlogZh(combatBlogZh));
    }

    /**
     * 删除知乎用户发布内容
     */
    @PreAuthorize("@ss.hasPermi('combat:blogzh:remove')")
    @Log(title = "知乎用户发布内容", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(combatBlogZhService.deleteCombatBlogZhByIds(ids));
    }



    /**
     * 发文趋势统计
     * @return
     */
    @ApiOperation(value = "根据用户id查看用户的发文趋势统计")
    @GetMapping(value = "/sendStatistics")
    public AjaxResult sendStatistics(String userId) {
        return AjaxResult.success(combatBlogZhService.sendStatistics(userId));
    }
    /**
     * 数量统计
     * @return
     */
    @ApiOperation(value = "数量统计")
    @GetMapping(value = "/numberStatistics")
    public AjaxResult numberStatistics(String userId) {
        return AjaxResult.success(combatBlogZhService.numberStatistics(userId));
    }
}
